################################## WARNING ####################################
#             this is just a prototype, use it only as reference              #
###############################################################################

# NOTE: SRCBUILDs are not parsed via Bash which means that not everything works
# as it does in Bash when it comes to the metadata variables handling. It is
# sourced only on compile, check, install, merge and remove.

version=5.14
description="File type identification utility"
depends=('zlib' 'glibc')
makedepends('foo' 'bar')
# variable expansion, must be preseeded with underscore
_base="file-$version"
sources=("ftp://ftp.astron.com/pub/file/$_base.tar.gz"
         "ftp://ftp.astron.com/pub/file/file-$version.tar.gz.sig"
         'dummy.patch')
pgpkeys=('12345678')
options=('!binaries' '!shared' '!static' 'man' 'mirror' 'missing' '!rpath'
         '!pycompile' 'debug')
backup=('etc/bar/baz.conf')

src_compile() {
    # working with full path and variable expansion
    cd "$SOURCE_DIR/$_base"
    patch -Np1 -i "$SOURCE_DIR/dummy.patch"

    ./configure --prefix=/usr
    make
}

src_check() {
    # working with full path (recommended)
    cd "$SOURCE_DIR/file-$version"
    make check
}

src_install() {
    # working with relative paths is possible too
    cd "file-$version"
    make DESTDIR="$INSTALL_DIR" install 
}

pre_install() {
    true
}

# functions can be re-used
post_install() {
    pre_install
}

pre_upgrade() {
    true
}

post_upgrade() {
    true
}

pre_remove() {
    true
}

post_remove() {
    true
}
